<?php 

/* Add 'uppercase' field to profile pages */

add_action( 'show_user_profile', 'my_show_extra_fields' );
add_action( 'edit_user_profile', 'my_show_extra_fields' );

function my_show_extra_fields( $user ) { ?>

	<h3><?php _e("WPWT Options"); ?></h3>

	<table class="form-table">

		<tr>
			<th><label for="uppercase"><?php _e("Uppercase"); ?></label></th>

			<td>
				<input type="checkbox" name="uppercase" id="uppercase" class="checkbox"<?php if ( get_the_author_meta( 'uppercase', $user->ID ) == '1' ) { echo ' checked="checked"'; } ?> /><br />
				<span class="description"><?php _e("Show the whole site in uppercase."); ?></span>
			</td>
		</tr>

	</table>
	
<?php }

add_action( 'personal_options_update', 'my_save_extra_fields' );
add_action( 'edit_user_profile_update', 'my_save_extra_fields' );

function my_save_extra_fields( $user_id ) {
  
	if ( !current_user_can( 'edit_user', $user_id ) )
		return false;
	
	update_user_meta( $user_id, 'uppercase', ( $_POST['uppercase'] == 'on' ? '1' : '0' ) );
	
}


/* Make the site uppercase if selected in profile */

add_action('wp_head', 'make_site_uppercase');
add_action('admin_head', 'make_site_uppercase');

function make_site_uppercase() {
  
  global $current_user;
  get_currentuserinfo();
  
  echo ( get_the_author_meta( 'uppercase', $current_user->ID ) == '1' ? '<style type="text/css">* { text-transform: uppercase !important; }</style>' : '' );
  
}

?>